import {mapGetters} from "vuex"

//存储公共的js资源
export const mixin = {
	
	methods: {
		//提示信息
		notify(title,type){
			this.$notify({
				title :title,
				type :type
			})
		},
		
		//获取图片地址this.getHost+
		attachImageUrl(srcUrl) {
			return srcUrl ? srcUrl : 'https://img95.699pic.com/element/40150/3689.png_300.png!/clip/0x300a0a0'
		},
		// //播放歌曲
		// toplay: function(id, url) {
		// 	this.$store.commit('setId', id);
		// 	this.$store.commit('setUrl', url);
		// },
		//模糊查询歌曲的方法
		getSong() {
			if (!this.$route.query.keywords) {
				this.$store.commit('setListOfSongs', [])
				this.notify('你输入的内容为空', 'warning');
					
			} else {
				name=this.$route.query.keywords;
				console.log(name,"sadasda")
				this.$axios.get('/SongServlet?method=queryDataLikeName', {
						params:{name}
					}).then((res) => {
						console.log("查歌名",res);
						if (!res.length) {
							this.$store.commit('setListOfSongs', [])
							this.notify('你要的结果跑到太空去了', 'warning');
						} else {
							this.$store.commit('setListOfSongs', res)
						}
					}).catch((err) => {
						console.log('请求失败了', err.message)
					})
			}
		}
		
	},

	// computed: {
	// 	...mapGetters({
	// 		getHost: 'getHost'
	// 	})
	// },
	// mounted() {
	// 	console.log('xxxx ', this.getHost)
	// }
}
